<template>
  <div id="welcome" class="animation"></div>
</template>

<script>
import * as echarts from 'echarts'

export default {
  name: 'welcomeAnimation',
  data () {
    return {}
  },
  methods: {
    goToIndex () {
      this.$router.push({name: 'index'})
    },
    initAnimation () {
      let obj = echarts.init(document.getElementById('welcome'))
      let option = {
        graphic: {
          elements: [
            {
              type: 'text',
              left: 'center',
              top: 'center',
              style: {
                text: '欢迎进入招生宣传活动网站',
                fontSize: 100,
                fontWeight: 'bold',
                lineDash: [0, 200],
                lineDashOffset: 0,
                fill: 'transparent',
                stroke: '#3eafe0',
                lineWidth: 1
              },
              keyframeAnimation: {
                duration: 3000,
                loop: false,
                keyframes: [
                  {
                    percent: 0.7,
                    style: {
                      fill: 'transparent',
                      lineDashOffset: 200,
                      lineDash: [200, 0]
                    }
                  },
                  {
                    // Stop for a while.
                    percent: 0.8,
                    style: {
                      fill: 'transparent'
                    }
                  },
                  {
                    percent: 1,
                    style: {
                      fill: 'black'
                    }
                  }
                ]
              }
            }
          ]
        }
      }
      obj.setOption(option)
    }
  },
  mounted () {
    this.initAnimation()
    setTimeout(() => this.goToIndex(), 7000)
  }
}
</script>

<style scoped>
.animation {
  width: 100%;
  height: 100%;
  background: url('../../../../../src/assets/bg2.svg');
}
</style>
